/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mygame;

import com.jme3.math.FastMath;
import com.jme3.scene.Spatial;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Timer;

/**
 *
 * @author Peter
 */
public class Arrow extends Projectile  {

    protected Spatial arrow;
    private float x,y,z,t=0;
    private Timer timer;


    
    Arrow(Spatial target, Main mainApp) {
        arrow = mainApp.getAssetManager().loadModel("Models/veza/projectile.j3o");
        
        arrow.setLocalTranslation(target.getLocalTranslation().add(1f,1f,1f));
        arrow.scale(0.5f, 0.5f, 0.5f);
        mainApp.getRootNode().attachChild(arrow);
        timer = new Timer(300, moveProjectile);
        timer.start();
        
    }
    ActionListener moveProjectile = new ActionListener() {
      public void actionPerformed(ActionEvent e) {
          if (arrow.getLocalTranslation().y > 0)
       {
           
       x = arrow.getLocalTranslation().x + 0.001f*t* FastMath.cos(60);
       y = arrow.getLocalTranslation().y + 0.001f*t* FastMath.sin(60) - 1/2 * 10 * t*t;
       z = arrow.getLocalTranslation().z ;
       //System.out.println((tower2.getLocalTranslation().y + 0.1f*t* FastMath.sin(30) - 1/2 * 10 * t*t) + "A" + (tower2.getLocalTranslation().y) + "A" +t);
       arrow.setLocalTranslation(x, y, z);
       System.out.println("BIOHASDDDDDDDDDDDDDD");
       
           t = t + 0.3f ;
       }
          else
          {
              timer.stop();
          }
      }

  };




    
}
